import type { FcPageConfig } from '@/types/fcform'
import { createItems } from './edit/formItems.ts'
import { createRule } from './edit/rules.ts'
import { createColums } from './table/columns.ts'
import { createSearchForm } from './search/index.ts'
export function usePageConfig(): FcPageConfig {
  return {
    KEY: 'id',
    pageProps: {
      createSearchForm,
      tools: {
        add: {
          auth: 'sys_dept_add',
        },
        del: false,
      },
    },
    table: {
      isPaging: false,
      getApi: '/admin/dept/tree',
      delApi: {
        api: '/admin/dept',
        method: 'delete',
        path: true,
      },
      dataMap: (data) => {
        return data.map((el) => {
          el.parentId = '0'
          return el
        })
      },
      initForm: {
        deptName: '',
      },
      createColums,
    },
    edit: {
      default: {
        key: 'deptId',
        addApi: '/admin/dept',
        editApi: {
          api: '/admin/dept',
          method: 'put',
        },
        defaultValue: {
          sortOrder: 1,
        },
        createItems,
        createRule,
      },
    },
  }
}
